<template>
  <div class="main">
    <view class="statement">
      点击阅读同意<view class="strong" @click="openStatement"
        >《飞鸽邮筒用户协议》》</view
      >
    </view>
  </div>
</template>
<script lang="ts">
import Vue from "vue";
import { mapState } from "vuex";
export default Vue.extend({
  computed: {
    ...mapState("setting", ["statement"]),
  },
  data() {
    return {
      checked: false,
    };
  },
  methods: {
    openStatement() {
      let url = this.statement;
      this.checked = true;
      uni.showLoading({ title: "正在打开" });
      uni.downloadFile({
        url: url,
        success: (res) => {
          var filePath = res.tempFilePath;
          uni.openDocument({
            filePath: filePath,
            success: (res) => {
              uni.hideLoading();

              console.log("打开文档成功");
            },
          });
        },
      });
    },
    isRead() {
      return this.checked;
    },
  },
});
</script>
<style lang="scss" scoped>
.main {
  border-radius: 15rpx;
  margin: 0 20rpx;
  padding: 20rpx;
  .statement {
    margin-top: 50rpx;
    margin-bottom: 50rpx;
    width: 100%;
    font-size: 20rpx;
    text-align: center;
    color: #d3d3d3;

    .strong {
      color: red;
      display: inline-block;
    }
  }
}
</style>
